package network;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.net.UnknownHostException;

public class SocketAdmin {
	Socket socket;
	ObjectOutputStream oos ;
	ObjectInputStream ois;

	public SocketAdmin(String host, int port, Protocol p) throws UnknownHostException, IOException{
		socket= new Socket(host, port) ;
		oos = new ObjectOutputStream(socket.getOutputStream());
		Receiver r =  new Receiver(socket, p);
		r.start();
		System.err.println("[Admin][Connexion] Thread reception lancé !");
	}
	
	public void send(Object o) throws IOException{
		oos.writeObject(o);
	}
	
	
	public void close() throws IOException{
		socket.close();
		oos.close();
		//ois.close();   Ouvert et fermé par le thread receiver
	}
}
